/* 博客文章系统路由
 * @Author: Leil 
 * @Date: 2018-08-24 14:45:47 
 * @Last Modified by: Leil
 * @Last Modified time: 2018-09-05 10:41:33
 */
// const express = require('express')
// const router = express.Router()
// const checkLogin = require('../middleware/check').checkLogin
const postService = require('../service/postService')

// router.use(checkLogin)

// router.get('/', function (req, res) {
//     // console.log('get posts....')
//     postService.getPosts()
//         .then(data => {
//             // console.log(data)
//             res.send(data)
//             return
//         })
//         .catch(error => {
//             console.log(error.errmsg)
//         })
// })

// module.exports = router


module.exports = function (app) {
    app.get('/getBlogs', function (req, res) {
        console.log("posts....................")
        postService.getPosts()
        .then(data => {
            // console.log(data)
            // console.log('start.................')
            // let start = Date.now()
            res.send(data)
            // let end = Date.now()
            // let interval = end - start
            // console.log(`发送的间隔时间:${interval}`)
            return
        })
        .catch(error => {
            console.log(error.errmsg)
        })
    })
}